//
//  MainViewController.m
//  YXLearnMasonry
//
//  Created by Rookie_YX on 16/10/27.
//  Copyright © 2016年 Rookie_YX. All rights reserved.
//

#import "MainViewController.h"
#import "MainTableViewCell.h"
#import "BaseViewController.h"
#import "BaseAnimViewController.h"
#import "WholeAnimViewController.h"
#import "PercenViewController.h"
#import "LableViewController.h"
#import "ScrollerBaseViewController.h"
#import "ScrollerComplexController.h"
#import "TableViewController.h"

@interface MainViewController ()
@property (strong, nonatomic) IBOutlet UITableView *MainTableView;
@property (nonatomic, copy) NSArray *listDataArr;
@property (nonatomic, copy) NSArray *pushVCArr;
@end

@implementation MainViewController

#pragma mark - life cycle
- (void)viewDidLoad {
  [super viewDidLoad];
}

#pragma mark -  UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  return self.listDataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  MainTableViewCell *cell = (MainTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MainCell" forIndexPath:indexPath];
  return cell;
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView willDisplayCell:(MainTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
  cell.titleLabel.text = self.listDataArr[indexPath.row];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  UIViewController *VC = self.pushVCArr[indexPath .row];
  [self.navigationController pushViewController:VC animated:YES];
}

#pragma mark - getting
- (NSArray *)listDataArr{
  if (!_listDataArr) {
    _listDataArr = @[
                         @"基础方法使用",
                         @"基本动画使用",
                         @"整体动画更新约束实例",
                         @"百分比约束",
                         @"Lable自适应高度约束",
                         @"Scrollview布局约束--基础篇",
                         @"Scrollview布局约束--复杂篇",
                         @"Tableview布局约束"];
  }
  return _listDataArr;
}

- (NSArray *)pushVCArr{
  if (!_pushVCArr) {
    _pushVCArr = @[
                   [[BaseViewController alloc]initWithTitle:@"基础方法使用"],
                   [[BaseAnimViewController alloc]initWithTitle:@"基本动画使用"],
                   [[WholeAnimViewController alloc]initWithTitle:@"整体动画更新约束实例"],
                   [[PercenViewController alloc]initWithTitle:@"百分比约束"],
                   [[LableViewController alloc]initWithTitle:@"Lable自适应高度约束"],
                   [[ScrollerBaseViewController alloc]initWithTitle:@"Scrollview布局约束--基础篇"],
                   [[ScrollerComplexController alloc]initWithTitle:@"Scrollview布局约束--复杂篇"],
                   [[TableViewController alloc]initWithTitle:@"Tableview布局约束"]];
  }
  return _pushVCArr;
}

@end
